﻿using System;
using Framework;

namespace View
{
    public class OrderSuccessView : ViewProxy
    {
        private Action _confirmCallback;
        
        public void SetConfirmCallback(Action callback)
        {
            _confirmCallback = callback;
        }

        private ClickTrigger _triggerConfirm;
        
        protected override void SetupView()
        {
            LoadRes("Views/Order/OrderSuccessView");
        }

        protected override void OnInit()
        {
            _triggerConfirm = ClickTrigger.Get(_transform.Find("Button_Confirm"));
            _triggerConfirm.AddClickListener(OnConfirmClick);
        }

        private void OnConfirmClick(params object[] args)
        {
            if (_confirmCallback != null)
            {
                _confirmCallback();
            }
            Close();
        }
    }
}